/*
 * @Author: sevenFunuction 1593215788@qq.com
 * @Date: 2023-12-10 15:35:35
 * @LastEditors: sevenFunuction 1593215788@qq.com
 * @LastEditTime: 2023-12-24 17:27:46
 * @FilePath: \dm-gpt-survey\dm-chatgpt-web\src\router\appRouter.tsx
 * @Description: 路由跳转文件
 */
// import { Spin } from "antd";
import { useState } from "react";
import { BrowserRouter as Router, Route, HashRouter, Routes, useNavigation } from "react-router-dom";
import routes from './routers'
import Login from "@/pages/login";

const isHash = import.meta.env.REACT_APP_ROUTER_ISHASH === "1"
const RouterBasename = import.meta.env.REACT_APP_ROUTERBASE || "/"



function appRouter() {

  // 设置变量loading默认值为true,以及setLoad改变loading的方法
  const [loading, setLoad] = useState(true)
  const userInfo = ''

  // if (!userInfo) {
  //   console.log('%c [ userInfo ]-30', 'font-size:13px; background:pink; color:#bf2c9f;', userInfo)
  //   return <Login />
  // } 

  const currentRouterObj  = window.location


  if (isHash) {
    return <HashRouter>
       {/* {routes.map((route, index) => (
          <Route key={route.path} path={route.path} Component={route.components} />  
        ))} */}
    </HashRouter>
  }

  return <Router basename={RouterBasename}>
        <Routes>  
          {routes.map((route, index) => (
            <Route key={route.path } path={route.path} element={route.components} /> 
          ))}
       </Routes>
  </Router>;
}

export default appRouter;